package cn.bandeqing.dispatch.controller;

import cn.bandeqing.base.resp.Resp;
import cn.bandeqing.dispatch.req.DispatchDetailReq;
import cn.bandeqing.dispatch.req.DispatchHandleReq;
import cn.bandeqing.dispatch.req.DispatchListReq;
import cn.bandeqing.dispatch.resp.DispatchDetailResp;
import cn.bandeqing.dispatch.resp.DispatchListResp;
import cn.bandeqing.dispatch.rpc.IDispatchRpc;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Tag(name = "调度")
@RequestMapping("/dispatch")
@RestController
public class DispatchController {

    @DubboReference
    private IDispatchRpc dispatchRpc;

    @Operation(summary = "订单详情")
    @PostMapping("/detail")
    public Resp<DispatchDetailResp> detail(@RequestBody @Valid DispatchDetailReq req) {
        return dispatchRpc.detail(req);
    }

    @Operation(summary = "接单处理")
    @PostMapping("/handle")
    public Resp<Void> handle(@RequestBody @Valid DispatchHandleReq req) {
        return dispatchRpc.handle(req);
    }

    @Operation(summary = "订单列表")
    @PostMapping("/list")
    public Resp<List<DispatchListResp>> list(@RequestBody @Valid DispatchListReq req) {
        return dispatchRpc.list(req);
    }

}
